# $Id: PKGBUILD 179978 2013-03-13 20:08:25Z jgc $
# Maintainer: Jan de Groot <jgc@archlinux.org>
# Contributor: Tom Gundersen <teg@jklm.no>
# Contributor: Eduardo Romero <eduardo@archlinux.org>
# Contributor: Damir Perisa <damir.perisa@bluewin.ch>

pkgname=libgphoto2
pkgver=2.5.1
pkgrel=1
pkgdesc="The core library of gphoto2, designed to allow access to digital camera by external programs."
arch=(i686 x86_64)
url="http://www.gphoto.org"
license=(LGPL)
depends=('libexif' 'libjpeg>=8' 'gd' 'libltdl' 'libusb-compat' 'libusb')
install=libgphoto2.install
options=('libtool')
source=(http://downloads.sourceforge.net/gphoto/${pkgname}-${pkgver}.tar.gz)
md5sums=('92780eb4baf7b512b86b5e7300ec91a5')

build() {
  cd "${srcdir}/${pkgname}-${pkgver}"
  ./configure \
	--prefix=/usr \
	--disable-rpath
  make
}

package() {
  cd "${srcdir}/${pkgname}-${pkgver}"
  make DESTDIR="${pkgdir}" install

  # Remove unused udev helper
  rm -rf "${pkgdir}/usr/lib/udev"

  install -m755 -d "${pkgdir}/usr/lib/udev/rules.d"
  LD_LIBRARY_PATH="${pkgdir}/usr/lib${LD_LIBRARY_PATH:+:}$LD_LIBRARY_PATH" \
  CAMLIBS="${pkgdir}/usr/lib/libgphoto2/${pkgver}" \
      "${pkgdir}/usr/lib/libgphoto2/print-camera-list" udev-rules version 175 > \
      "${pkgdir}/usr/lib/udev/rules.d/40-gphoto.rules"

  # Remove recursive symlink
  rm -f "${pkgdir}/usr/include/gphoto2/gphoto2"
}
